package com.fc.mall.dto;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Map;

@Getter
@Setter
@NoArgsConstructor
public class WXPayTransferResult {
    public WXPayTransferResult(Map<String, String> map) {
        this.setMchAppId(map.get("mch_appid"));
        this.setMchId(map.get("mchid"));
        this.setDeviceInfo(map.get("device_info"));
        this.setNonceStr(map.get("nonce_str"));
        this.setPaymentNo(map.get("payment_no"));
        this.setPaymentTime(map.get("payment_time"));
        if (map.get("result_code") != null) {
            this.setResultCode(ResultCode.valueOf(map.get("result_code")));
        }
        if (map.get("return_code") != null) {
            this.setReturnCode(ReturnCode.valueOf(map.get("return_code")));
        }
        this.setPartnerTradeNo(map.get("partner_trade_no"));
        this.setErrCode(map.get("err_code"));
        this.setErrCodeDes(map.get("err_code_des"));
        this.setReturnMsg(map.get("return_msg"));
    }

    private String mchAppId;

    private String mchId;

    private String nonceStr;

    private String deviceInfo;

    private ReturnCode returnCode;

    private String returnMsg;

    private ResultCode resultCode;

    private String errCode;

    private String errCodeDes;

    private String partnerTradeNo;

    private String paymentNo;

    private String paymentTime;

    public enum ResultCode {
        SUCCESS,
        FAIL
    }

    public enum ReturnCode {
        SUCCESS,
        FAIL
    }
}
